﻿/*=================================================================
* 版权信息：Copyright (C) 2005-2011 捷点科技 All Rights Reserved.
* 文件名称：CNVP_Products.cs
* 创建标识：曾乃强 15158756652 2011-03-18 01:03:05
* 修改标识：
* 功能描述：
===================================================================*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using CNVP.Framework;
using CNVP.Framework.Helper;

namespace CNVP.JShop.BLL 
{
    /// <summary>
    /// 对*CNVP_Products*操作(针对业务层)的实现
    /// </summary>
    public class CNVP_Products
    {
        DAL.CNVP_Products dal = new DAL.CNVP_Products();
        
        #region BLL
        #region 添加
        /// <summary>
        /// 添加
        /// </summary>
        public int Add_CNVP_Products(Model.CNVP_Products obj)
        {
            return dal.Insert(obj);
        }
        #endregion
        
        #region 修改
        /// <summary>
        /// 修改
        /// </summary>
        public int Update_CNVP_Products(Model.CNVP_Products obj)
        {
            return dal.Update(obj);
        }
        #endregion
        
        #region 删除
        /// <summary>
        /// 删除
        /// </summary>
        public int Delete_CNVP_Products(Model.CNVP_Products obj)
        {
            return dal.Delete(obj);
        }
        
        /// <summary>
        /// 删除,生成列的主键列构成的参数列表
        /// </summary>
        public int Delete_CNVP_Products(int ID)
        {
            return this.Delete_CNVP_Products(new Model.CNVP_Products() {
            
                 ID=ID
            });
        }
        #endregion 
        
        /// <summary>
        /// 查看单个
        /// </summary>
        public Model.CNVP_Products GetSingle_CNVP_ProductsById(int ID)
        {
            return dal.LoadById(ID);
        }
        /// <summary>
        /// 查看单个
        /// </summary>
        public Model.CNVP_Products GetSingle_CNVP_ProductsByIdAndDeliveryFreightID(int ID, int DeliveryFreightID)
        {
            return dal.LoadByIdAndDeliveryFreightID(ID, DeliveryFreightID);
        }

        public Model.CNVP_Products GetSingle_CNVP_ProductsByIdandAllowReview(int ID)
        {
            return dal.LoadByIdandAllowReview(ID);
        }

        public DataTable GetSingleProductForTemplate(int productID)
        {
            return dal.GetSingleProductForTemplate(productID);
        }
        public DataTable GetTopProductForTemplate()
        {
            return dal.GetTopProductForTemplate();
        }
        /// <summary>
        /// 查看全部
        /// </summary>
        public List<Model.CNVP_Products> GetAll_CNVP_Products(string sqlWhere)
        {
            return dal.LoadAll(sqlWhere);
        }
        /// <summary>
        /// 查看全部
        /// </summary>
        public List<Model.CNVP_Products> GetAll_CNVP_Products()
        {
            return this.GetAll_CNVP_Products("");
        }

        public List<Model.CNVP_Products> GetDeliveryFreightID_CNVP_Products_InProductIDSBroupBy(string ProductIDS)
        {
            return dal.LoadDeliveryFreightIDInProductIDSBroupBy(ProductIDS);
        }


        #endregion

        public DataTable GetPage(string PageName, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
        {
            return dal.GetPage(PageName, PageIndex, PageSize, out RecordCount, out PageCount, SqlCondition);
        }

        public DataTable GetPage(string PageName, int PageIndex, int PageSize, string OrderFields, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
        {
            return dal.GetPage(PageName, PageIndex, PageSize, OrderFields, out RecordCount, out PageCount, SqlCondition);
        }

        public DataTable GetPageKey(string PageName, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
        {
            return dal.GetPageKey(PageName, PageIndex, PageSize, out RecordCount, out PageCount, SqlCondition);
        }

        
        public List<Model.CNVP_Products> GetCNVP_ProductsListBy_CNVP_Products_REFERENCE_CNVP_Branks(int BrandID)
        {
            return dal.QurryListFK_CNVP_Products_REFERENCE_CNVP_Branks(BrandID);
        }

        /// <summary>
        /// 放入回收站
        /// </summary>
        public int Update_CNVP_ProductsByIsDelete(Model.CNVP_Products obj)
        {
            return dal.UpdateByIsDelete(obj);
        }
        public int GetTopProductDetailID(int columnID)
        {
            return dal.GetTopProductDetailID(columnID);
        }
        public int UpdateByProductState(Model.CNVP_Products obj)
        {
            return dal.UpdateByProductState(obj);
        }
        /// <summary>
        /// 配送更新库存 -库存
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int UpdateNum(int ProductsID, int OrderNum, int type)
        {
            return dal.UpdateNum(ProductsID, OrderNum, type);
        }

    }
}

